//
//  main.c
//  Gold_Point
//
//  Created by 封皓君 on 2019/11/04.
//  Copyright © 2019年 封皓君. All rights reserved.
//

#include<stdlib.h>
#include<string.h>
int point()
{
    int i,j,k,M,N,jiafen,koufen;
    int min=0,max=0;
    int m[100], n[100];
    double average, G,sum = 0.0;
    int score[100];
    
    printf("Welcome to Gotham!\n");
    printf("游戏轮数：");
    scanf("%d", &M);
    printf("游戏人数：");
    scanf("%d", &N);
    printf("胜利者加分：");
    scanf("%d", &jiafen);
    printf("失败者扣分：");
    scanf("%d", &koufen);
    memset(score,0,sizeof(int)*N);
    for (i = 0; i < M; i++)
    {
        min=0;
        max=0;
        printf("\n第%d轮游戏：\n",i+1);
        for (j = 0; j < N; j++)
        {
            printf("请%d号玩家输入一个0-100的数：\n",j+1);
            scanf("%d",&m[j]);
            sum = sum + m[j];
        }
        average = sum/N;
        G=average*0.618;
        for (j = 0; j < N; j++)
        {
            n[j] = m[j] - G;
            n[j]=(n[j]>0) ? n[j] : n[j]*(-1);
            max=(n[j]<n[max]) ? max:j;
            min=(n[j]<n[min]) ? j:min;
        }
        //printf("\n%d\n",max);
        //printf("%d\n",min);
        score[min]+=jiafen;
        score[max]-=koufen;
        for(k=0;k<N;k++)
        {
            printf("第%d人本轮后总分数为%d:\t\n",k+1,score[k]);
        }
        sum = 0;
        //printf("黄金点是%f\n", G);
    }
    return 0;
}

int main()
{
    point();
    //system("pause");
}